﻿define([], function(){
    var tpl = {};
    tpl.init1= function(){
        var html = '';
        html += basic();
        return html;
    };
    tpl.init2= function(){
        var html = '';
        html += bsid2();
        return html;
    };
    tpl.init3 = function(){
        var html = '';
        html += behavior();
        return html;
    };
    tpl.init4 = function(){
        var html = '';
        html += tabs();
        return html;
    };
    tpl.init5 = function(){
        var html = '';
        html += node();
        return html;
    };
    tpl.init6 = function(){
        var html = '';
        html += resultInfo();
        return html;
    };
    tpl.init8 = function(){
        var html = '';
        html += history();
        return html;
    };
    tpl.init9 = function(){
        var html = '';
        html += stageList();
        return html;
    };
    tpl.init10 = function(){
        var html = '';
        html += tab();
        return html;
    };
    tpl.init11 = function(){
        var html = '';
        html += monthList();
        return html;
    };
    tpl.init12 = function(){
        var html = '';
        html += behaviorTab();
        return html;
    };
    tpl.dialog = function(){
        var html = '';
        html += dialog();
        return html;
    };
    /*
    * 评估问卷模板
    * */
    var basic = function(){
        return '<script type = "text/html" id="basic2-tpl">'+
                    '<li>姓名：{{userName}}</li>'+
                    '<li>{{if isPremature == 1}}实际月龄{{else if isPremature == 2}}纠正月龄{{/if}}：<span class = "actualMonthlyAge">{{monthAge}}</span>月龄</li>'+
                    '<li>测试日期：{{testDate}}</li>'+
                    '<li>智力智龄：{{ if intelligenceAge}}{{intelligenceAge}}月龄{{else}}未知{{/if}}</li>'+
                    '<li>运动智龄：{{ if sportsAge}}{{sportsAge}}月龄{{else}}未知{{/if}}</li>'+
                    '<li>身高：<input type="text" class="form-control" id= "height" value = "{{height}}" {{if heightFlag == 1}}disabled{{/if}}/>cm</li>'+
                '</script>'
    };
    var bsid2 = function(){
        return '<script type = "text/html" id = "bsid2-tpl" >'+
                    '<div class="question">'+
                        '<ul class="clearfix ques-title">'+
                            '<li>题号</li>'+
                            '<li>题目</li>'+
                            '<li>评分标准</li>'+
                            '<li>评分</li>'+
                            '<li>注释</li>'+
                        '</ul>'+
                        '{{each data as value}}'+
                        '<ul class="clearfix ques-detail" quesId="{{if value.mr}}{{value.mr}}.{{/if}}{{value.id}}">'+
                            '<li><div class="triangle"></div>{{if value.mr}}{{value.mr}}{{/if}}{{value.id}}</li>'+
                            '<li>{{value.desc}}</li>'+
                            '<li>'+
                                '{{value.score}}'+
                                '{{if value.careful}}'+
                                '<p class="attention">{{value.careful}}</p>'+
                                '{{/if}}'+
                            '</li>'+
                            '<li stage = "{{value.stage}}" id="{{if value.mr}}{{value.mr}}.{{/if}}{{value.id}}" service="{{value.service}}" type="{{value.type}}">'+
                                '<div class="options {{if value.value>=0}}{{if value.value == 1}} green {{else}} grey {{/if}}{{/if}}">'+
                                    '<div><i class="fa fa-check" aria-hidden="true"></i></div>'+
                                '</div>'+
                                '<div class="options {{if value.value>=0}}{{if value.value == 1}} grey {{else}} green {{/if}}{{/if}}">'+
                                    '<div><i class="fa fa-times" aria-hidden="true"></i></div>'+
                                '</div>'+
                            '</li>'+
                            '<li>'+
                                '<textarea name="tips" class="form-control"  placeholder = "若有注释请输入">{{value.note}}</textarea>'+
                            '</li>'+
                        '</ul>'+
                        '{{/each}}'+
                    '</div>'+
                '</script>'
    };
    var behavior = function(){
        return '<script type = "text/html" id="behavior-tpl">'+
                '<div class="behavior" item = "{{item}}">'+
                    '<p class="attention">{{careful}}</p>'+
                    '{{each questions as value}}'+
                        '<ul id="{{value.id}}" {{if value.id == 4}} class="ul-4"{{/if}} {{if value.id == 29}} class="ul-29"{{/if}}>'+
                            '<li class="behavior-item {{if careful}} behavior-careful {{/if}}">'+
                                '<div>'+
                                    '<div>{{value.response.desc}}</div>'+
                                    '<div class="behavior-option {{if careful}} behavior-score{{/if}} {{value.classType}}">'+
                                        '{{if !value.responseOthers}}'+
                                            '<ul  class="clearfix">'+
                                            '{{each value.response.activity as ques}}'+
                                            '<li {{if ques.status == 1}} class="be-checked" {{/if}}>{{ques.check}}</li>'+
                                            '{{/each}}'+
                                            '</ul>'+
                                            '<p class="attention">{{value.ownCareful}}</p>'+
                                        '{{else}}'+
                                            '<textarea class="form-control" placeholder="{{value.responseOthers}}">{{value.responseNote}}</textarea>'+
                                        '{{/if}}'+
                                    '</div>'+
                                '</div>'+
                                '{{if !value.responseOthers}}'+
                                '<div>'+
                                    '<div>附加记录</div>'+
                                    '<div class="behavior-other">'+
                                        '<ul class="clearfix">'+
                                            '{{each value.append as ques}}'+
                                            '<li {{if ques.status == 1}} class="be-checked" {{/if}}>{{ques.check}}</li>'+
                                            '{{/each}}'+
                                        '</ul>'+
                                        '{{if value.appendOthers}}'+
                                        '<textarea class="form-control" placeholder="{{value.appendOthers}}">{{value.appendNote}}</textarea>'+
                                        '{{/if}}'+
                                    '</div>'+
                                '</div>'+
                                '{{/if}}'+
                            '</li>'+
                        '</ul>'+
                    '{{/each}}'+
                '</div>'+
                '</script>'
    };
    var tab = function(){
         return '<script type = "text/html" id="bsidTab-tpl">'+
                    '<div class="clearfix selected-tab" quesType = "智力" monthAge = {{intellgenceAge}} start = "{{intellgenceStart}}" end = "{{intellgenceEnd}}" isEnd="{{isEnd}}">'+
                        '<span>智力量表</span>'+
                        '<span>{{if intellgence }} {{intellgence}} {{else}}<i class="fa fa-question-circle" aria-hidden="true"></i>{{/if}}</span>'+
                    '</div>'+
                    '<div class="clearfix hide" quesType = "运动" monthAge = {{sportsAge}} start = "{{sportsStart}}" end = "{{sportsEnd}}" isEnd="{{isEnd}}">'+
                        '<span>运动量表</span>'+
                        '<span>{{if sports}} {{sports}} {{else}}<i class="fa fa-question-circle" aria-hidden="true"></i>{{/if}}</span>'+
                    '</div>'+
                    '<div class="clearfix hide" quesType = "行为" isEnd="{{isEnd}}">行为量表</div>'+
                '</script>'
    };
    var tabs = function(){
        return '<script type = "text/html" id="tabs-tpl">'+
                    '<div class="checked">情景</div>'+
                    '<div>题号 | 月龄</div>'+
                '</script>'
    };
    var stageList = function(){
        return '<script type = "text/html" id="stage-tpl">'+
                    '<li group="prev" class="{{if prev == 0 }}forbidden{{/if}}" index = {{prev}} quesType = "{{quesType}}"><i class="fa fa-caret-up" aria-hidden="true"></i></li>'+
                    '{{each listData as value}}'+
                        '<li group = "item" stage = "{{value.stage}}" class="{{if !value.showFlag}}hide{{/if}}" idArr="{{value.idArr}}" index="{{value.index}}">{{value.stage}}</li>'+
                    '{{/each}}'+
                    '<li group="next" class="{{if next >= length }}forbidden{{/if}}"  index = {{next}} quesType = "{{quesType}}"><i class="fa fa-caret-down" aria-hidden="true"></i></li>'+
                '</script>'
    }
    var monthList = function(){
        return '<script type = "text/html" id="month-tpl">'+
                    '<li group="prev" class="{{if prev == 0 }}forbidden{{/if}}" index = {{prev}} quesType = "{{quesType}}"><i class="fa fa-caret-up" aria-hidden="true"></i></li>'+
                    '{{each listData as value}}'+
                        '<li group = "item" stage ="{{value.stage}}" quesId = "{{value.id}}" class="{{if !value.showFlag}}hide{{/if}} {{if value.value >=0}}{{if value.value ==0}}done{{else}}transition{{/if}}{{/if}}">'+
                            '{{value.id}}&nbsp;|&nbsp;'+
                            '<span>'+
                                '{{if value.value == 1}}<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                '{{else if value.value == 0}}<i class="fa fa-minus-circle" aria-hidden="true"></i>'+
                                '{{else}}{{value.monthAge}}{{/if}}'+
                            '</span>'+
                        '</li>'+
                    '{{/each}}'+
                    '<li group="next" class="{{if next >= length }}forbidden{{/if}}" index = {{next}} quesType = "{{quesType}}"><i class="fa fa-caret-down" aria-hidden="true"></i></li>'+
                '</script>'
    }
    var behaviorTab = function(){
        return '<script type = "text/html" id="behaviorTab-tpl">'+
                    '{{each data as value,i}}'+
                        '<li item ="{{value.item}}" class="{{if i == 0 }}be-selected{{/if}} {{if value.flag == 1}}be-done{{/if}}">{{value.item}}</li>'+
                    '{{/each}}'+
                '</script>'
    }
    var node = function(){
        return '<script type = "text/html" id="node2-tpl">'+
                    '<ul class="basic-number">'+
                        '<li>基础水平</li>'+
                        '<li>{{if basic}}第{{basic}}题{{else}}未检测到{{/if}}</li>'+
                    '</ul>'+
                    '<ul class="max-basic">'+
                        '<li>最高水平</li>'+
                        '<li>{{if max}}第{{max}}题{{else}}未检测到{{/if}}</li>'+
                    '</ul>'+
                '</script>'
    };
    /*
    * 评估报告模板：
    * */
    var resultInfo = function(){
        return '<script type = "text/html" id="resultInfo-tpl">'+
            '<div class="p-0-15">'+
                '<ul class="clearfix user-info">'+
                    '<li>姓名：{{userName}}</li>'+
                    '<li>性别：{{if gender == "N"}}男{{else}}女{{/if}}</li>'+
                    '<li>月龄：{{monthAge}}月龄</li>'+
                    '<li>编号：{{if newId}}{{newId}}{{else}}-&nbsp;{{/if}}</li>'+
                '</ul>'+
                '<div class="clearfix info">'+
                    '<div class="basic-info">'+
                        '<p>测试日期：{{testTime}}</p>'+
                        '<p>出生日期：{{birthday}}</p>'+
                        '<p>年&emsp;&emsp;龄：{{age}}</p>'+
                    '</div>'+
                    '<div class="basic-info">'+
                        '<table class="table">'+
                            '<tr><td></td><td>粗分</td><td>发育指数</td><td>百分位</td><td>智龄</td></tr>'+
                            '<tr>'+
                                '<td>智力发育</td>'+
                                '<td>{{if MRmrSocre}}{{MRmrSocre}}{{else}}-{{/if}}</td>'+
                                '<td>{{if MRmdiOrpdi}}{{MRmdiOrpdi}}{{else}}-{{/if}}</td>'+
                                '<td>{{if MRpercent}}{{MRpercent}}{{else}}-{{/if}}</td>'+
                                '<td>{{if MRintelligenceAge}}{{MRintelligenceAge}}{{else}}-{{/if}}</td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td>运动发育</td>'+
                                '<td>{{if PRprSocre}}{{PRprSocre}}{{else}}-{{/if}}</td>'+
                                '<td>{{if PRmdiOrpdi}}{{PRmdiOrpdi}}{{else}}-{{/if}}</td>'+
                                '<td>{{if PRpercent}}{{PRpercent}}{{else}}-{{/if}}</td>'+
                                '<td>{{if PRintelligenceAge}}{{PRintelligenceAge}}{{else}}-{{/if}}</td>'+
                            '</tr>'+
                        '</table>'+
                   ' </div>'+
                '</div>'+
                '<p class="c-default">' +
                    '本胎为第<u> {{if nfyyParity}}{{nfyyParity}}{{else}}-{{/if}} </u>胎,'+
                    '第<u> {{if nfyyProductiontimes}}{{nfyyProductiontimes}}{{else}}-{{/if}} </u>产，' +
                    '出生体重<u> {{if nfyybirthweight}}{{nfyybirthweight}}{{else}}-{{/if}} </u>千克，' +
                    '身高<u> {{if height}}{{height}}{{else}}-{{/if}} </u>厘米。' +
                    '喂养方式：<u> {{if nfyyfeedway}}{{nfyyfeedway}}{{else}}-{{/if}}&nbsp; </u>' +
                '</p>'+
            '</div>'+
            '<div class="item-title">结论</div>'+
            '<div class="p-0-15">'+
                '<p>' +
                    '受试婴幼儿在《贝利婴幼儿发育量表》测试结果中结果显示，受试者与同年龄婴幼儿比较，其智力发育比'+
                    '<u class="c-default">{{if MRpercent}} {{MRpercent}} {{else}} - {{/if}}</u>'+
                    '的人好，其运动发育比<u class="c-default">{{if PRpercent}} {{PRpercent}} {{else}} - {{/if}}</u>的人好。'+
                '</p>'+
                '<p>'+
                    '<label >发育等级：</label>'+
                    '发育等级：<u class="c-default">{{if MRdevelopmentGrade}}{{MRdevelopmentGrade}}{{else}} - {{/if}} </u>&nbsp;&nbsp;&nbsp;&nbsp;'+
                    '运动发育：<u class="c-default">{{if PRdevelopmentGrade}}{{PRdevelopmentGrade}}{{else}} - {{/if}} </u>&nbsp;&nbsp;&nbsp;&nbsp;'+
                    '智力发育与运动发育比较：<u class="c-default">{{if difference}}{{difference}}{{else}} - {{/if}}&nbsp;</u>'+
                '</p>'+
            '</div>'+
            '</script>'
    };
    var history = function(){
        return '<script type = "text/html" id="history-tpl">'+
                    '{{each data as value}}'+
                    '<li answerId = "{{value.answerId}}"><span class="right"></span>{{value.testTime}}({{value.testAge}})</li>'+
                    '{{/each}}'+
                '</script>'
    };
    /*
    * 弹窗模板
    * */
    var dialog = function(){
        return '<script type = "text/html" id="dialog-tpl">'+
                '<div class="modal fade" tabindex="-1" role="dialog" id="myModal">'+
                    '<div class="modal-dialog" role="document">'+
                        '<div class="modal-content">'+
                            '<div class="modal-header">'+
                                '<h4 class="modal-title">{{title}}</h4>'+
                            '</div>'+
                        '<div class="modal-body">{{tips}}</div>'+
                        '<div class="modal-footer">'+
                            '<button type="button" class="btn btn-success" data-dismiss="modal" flag = "2">{{btn2}}</button>'+
                            '<button type="button" class="btn btn-success" data-dismiss="modal" flag = "1">{{btn1}}</button>'+
                            '{{if !flag}}'+
                            '<button type="button" class="btn {{if flagColor == 1}} btn-success {{else}} btn-default {{/if}}" data-dismiss="modal" flag = "0">{{btn0}}</button>'+
                            '{{/if}}'+
                        '</div>'+
                        '</div>'+
                    '</div>'+
                '</div>'+
                '</script>'
    };
    return tpl;
});